package com.justgame.project.service.system.service.basic;

import com.justgame.project.service.system.entity.SysHomeBanner;
import com.justgame.project.service.system.query.SysHomeBannerQuery;
import com.justgame.project.service.system.wrapper.SysHomeBannerWrapper;
import com.justgame.project.base.servcice.IBasicService;
import org.springframework.util.Assert;
import java.lang.Integer;
import org.springframework.lang.NonNull;
import java.lang.String;

/**
 *
 * 首页轮播信息表服务自定义查询类
 *
 * @@tableName sys_home_banner
 * @author Zwb
 */
@SuppressWarnings("all")
public interface BasicSysHomeBannerService extends IBasicService<SysHomeBannerQuery,SysHomeBanner,SysHomeBannerWrapper> {

   /**
    * 新增创建
    * @param title 标题
    * @param description 描述
    * @param coverFile 封面图
    * @param link 链接地址
    * @param order 排序
    */
   default SysHomeBanner baseAdd(String title, String description, String coverFile, String link, Integer order){
      SysHomeBanner sysHomeBanner = new SysHomeBanner();
      sysHomeBanner.setTitle(safeValue(title, null));
      sysHomeBanner.setDescription(safeValue(description, null));
      sysHomeBanner.setCoverFile(safeValue(coverFile, null));
      sysHomeBanner.setLink(safeValue(link, null));
      sysHomeBanner.setOrder(safeValue(order, null));
      save(sysHomeBanner);
      return sysHomeBanner;
   }

   /**
    * 更新
    * @param title 标题
    * @param description 描述
    * @param coverFile 封面图
    * @param link 链接地址
    * @param order 排序
    */
   default boolean baseUpdate(@NonNull SysHomeBanner sysHomeBanner,String title, String description, String coverFile, String link, Integer order){
      Assert.notNull(order,"必须提供排序");
      Assert.notNull(title,"必须提供标题");
      Assert.notNull(coverFile,"必须提供封面图");
      Assert.notNull(description,"必须提供描述");
      Assert.notNull(link,"必须提供链接地址");
      Assert.notNull(sysHomeBanner.getId(),"必须提供主键ID");
      sysHomeBanner.setTitle(safeValue(title, null));
      sysHomeBanner.setDescription(safeValue(description, null));
      sysHomeBanner.setCoverFile(safeValue(coverFile, null));
      sysHomeBanner.setLink(safeValue(link, null));
      sysHomeBanner.setOrder(safeValue(order, null));
      return updateById(sysHomeBanner);
   }

}